#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	long long n,q,v;cin>>n>>q>>v;
	if(v-q>n||v%n<=q%n&&v!=n) cout<<n-1;
	else cout<<v%n;
	return 0;
}
